﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;

public partial class Management_Room : System.Web.UI.UserControl
{
    public String SelectedValue
    {
        get
        {
            return DropDownList1.SelectedValue;
        }
    }

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            DropDownList1.DataBind();
        }
    }

    public void loadRoomByWardID(int WardID)
    {
        SqlConnection con = new SqlConnection(GlobalConstant.CONNECTION_STRING);
        con.Open();
        string sql = "SELECT [RoomName], [ID] FROM [tbRoom] WHERE IDWARD=" + WardID + " ORDER BY [RoomName]";
        SqlCommand cmd = new SqlCommand(sql,con);
        SqlDataReader reader = cmd.ExecuteReader();
        DropDownList1.DataSource = reader;
        DropDownList1.DataTextField = "RoomName";
        DropDownList1.DataValueField = "ID";
        DropDownList1.DataBind();
        reader.Close();
        con.Close();
    }
}